/*
 * @Author: szx
 * @Date: 2021-12-31 12:51:01
 * @LastEditTime: 2021-12-31 13:00:06
 * @Description:
 * @FilePath: \leetcode\500-599\507\507.js
 */
/**
 * @param {number} num
 * @return {boolean}
 */
var checkPerfectNumber = function (num) {
    if (num == 1) return false;
    const size = Math.floor(Math.sqrt(num));
    const arr = [1];
    for (let i = 2; i <= size; i++) {
        if (num % i == 0) {
            arr.push(i);
            arr.push(num / i);
        }
    }
    const sum = arr.reduce((prev, curr) => prev + curr, 0);
    if (sum == num) return true;
    return false;
};
console.log(checkPerfectNumber(2));
